from flask import Flask
from .models import db


def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:123456@127.0.0.1/myAppFlask'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
    app.secret_key = '1234567'
    from app.blueprint.login import login as login_blueprint
    from app.blueprint.register import register as register_blueprint
    from app.blueprint.personalcenter import usercenter as usercenter_blueprint
    from app.blueprint.homepage import index as index_blueprint
    from app.blueprint.publish import publish as publish_blueprint
    from app.blueprint.admin import admin as admin_blueprint
    from app.blueprint.article import article as article_blueprint
    from app.API import api as api_blueprint
    app.register_blueprint(login_blueprint)
    app.register_blueprint(register_blueprint)
    app.register_blueprint(index_blueprint)
    app.register_blueprint(usercenter_blueprint)
    app.register_blueprint(publish_blueprint)
    app.register_blueprint(admin_blueprint)
    app.register_blueprint(article_blueprint)
    app.register_blueprint(api_blueprint)
    db.init_app(app)
    return app
